/*
 * @Author: error: git config user.name & please set dead value or install git
 * @Date: 2024-06-27 16:11:47
 * @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @LastEditTime: 2024-06-27 16:15:07
 * @FilePath: /资源库/src/API/request.ts
 */
import BaseURL from "./BaseURL";
import axios from "axios";
import { message } from "antd";
const instance = axios.create({
    baseURL: BaseURL.baseURL,
    timeout: 10000,
    headers: {
        "Content-Type": "application/json",
    },
});

instance.interceptors.request.use(
    config => {
        return config;
    },
    error => {
        message.open({ type: "error", content: error });
        return Promise.reject(error);
    }
);

instance.interceptors.response.use(
    response => {
        if (response.data.code === "1") {
            return response.data;
        }
        message.open({ type: "error", content: response.data.msg });
        return;
    },
    error => {
        message.open({ type: "error", content: error });
        return Promise.reject(error);
    }
);
export default instance;
